import { Inject, Injectable, LoggerService } from '@nestjs/common';
import { LogLevel } from '@nestjs/common/services/logger.service';

// 自定义的日志
@Injectable()
export class MyLogger implements LoggerService {
  @Inject('LOGGER_CONFIG') private readonly config: any;

  log(message: any, ...optionalParams: any[]): any {
    console.log(this.config.enable);
    if (this.config.enable) {
      console.log(`[LOG] ${message}`, ...optionalParams);
    }
  }

  error(message: any, ...optionalParams: any[]): any {
    console.log(`[error] ${message}`, ...optionalParams);
  }

  warn(message: any, ...optionalParams: any[]): any {
    console.log(`[warn] ${message}`, ...optionalParams);
  }

  debug(message: any, ...optionalParams: any[]): any {
    console.log(`[debug] ${message}`, ...optionalParams);
  }

  verbose(message: any, ...optionalParams: any[]): any {
    console.log(`[verbose] ${message}`, ...optionalParams);
  }

  fatal?(message: any, ...optionalParams: any[]): any {
    console.log(`[fatal] ${message}`, ...optionalParams);
  }

  setLogLevels?(levels: LogLevel[]): any {}
}
